﻿using System;
using UnityEngine;

namespace RootMotion.Demos
{
	// Token: 0x020000D7 RID: 215
	public class WeaponRifle : WeaponBase
	{
		// Token: 0x06000644 RID: 1604 RVA: 0x00039518 File Offset: 0x00037718
		public override void Fire()
		{
			this.muzzleFlash.Emit(1);
			this.smokeEmission = 10f;
			RaycastHit raycastHit;
			if (!Physics.Raycast(this.shootFrom.position, this.shootFrom.forward, out raycastHit, this.range, this.hitLayers))
			{
				return;
			}
			Vector3 position = raycastHit.point + raycastHit.normal * 0.01f;
			UnityEngine.Object.Instantiate(this.bulletHole, position, Quaternion.LookRotation(-raycastHit.normal));
			this.bulletHit.transform.position = position;
			this.bulletHit.Emit(20);
		}

		// Token: 0x06000645 RID: 1605 RVA: 0x000395CC File Offset: 0x000377CC
		public void Update()
		{
			this.smokeEmission = Mathf.Max(this.smokeEmission - Time.deltaTime * this.smokeFadeOutSpeed, 0f);
			ParticleSystem.EmissionModule emission = this.muzzleSmoke.emission;
			emission.enabled = (this.smokeEmission > 0f);
			emission.rate = new ParticleSystem.MinMaxCurve(this.smokeEmission);
		}

		// Token: 0x04000575 RID: 1397
		[Header("Shooting")]
		public Transform shootFrom;

		// Token: 0x04000576 RID: 1398
		public float range = 300f;

		// Token: 0x04000577 RID: 1399
		public LayerMask hitLayers;

		// Token: 0x04000578 RID: 1400
		[Header("FX")]
		public ParticleSystem muzzleFlash;

		// Token: 0x04000579 RID: 1401
		public ParticleSystem muzzleSmoke;

		// Token: 0x0400057A RID: 1402
		public Transform bulletHole;

		// Token: 0x0400057B RID: 1403
		public ParticleSystem bulletHit;

		// Token: 0x0400057C RID: 1404
		public float smokeFadeOutSpeed = 5f;

		// Token: 0x0400057D RID: 1405
		public float smokeEmission;
	}
}
